package com.sunwayhorizo.health.hl7.rim;

import com.sunwayhorizo.health.hl7.common.DataTypeUtil;
import com.sunwayhorizo.health.hl7.common.Hl7Exception;
import com.sunwayhorizo.health.hl7.datatypes.CE;
import com.sunwayhorizo.health.hl7.datatypes.ST;
import com.sunwayhorizo.health.hl7.persistent.RimCoreActCdSets;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.NamedQuery;


import static com.sunwayhorizo.health.hl7.vocabulary.ActCdSetCode.*;


@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorValue("ACCT")
@NamedQuery(name = "Account.findAll", query = "select o from Account o")
public class Account extends Act implements Serializable {
    
/*    public IVL_MO allowedBalanceQuantity;
    public MO balanceAmt;
    public CE currencyCode;
    public RTO_MO_PQ interestRateQuantity;
    public ST name;
*/    
    public Account() throws Hl7Exception {
    }
    
    
/*    public void setAllowedBalanceQuantity(IVL_MO allowedBalanceQuantity) {
        this.allowedBalanceQuantity = allowedBalanceQuantity;
    }

    public IVL_MO getAllowedBalanceQuantity() {
        return allowedBalanceQuantity;
    }

    public void setBalanceAmt(MO balanceAmt) {
        this.balanceAmt = balanceAmt;
    }

    public MO getBalanceAmt() {
        return balanceAmt;
    }
*/
    public void setCurrencyCode(CE ce) {
    	if(null != ce && ce.codeSystemEnName()!=null && ce.codeName()!= null)
        {
            setRimCoreActCdSets(ce, ACCURRCDSETCODE);
        }
        else
        {
            this.setAcCurrCode(ce.code().toString());
        }
    }

    public CE getCurrencyCode() throws Hl7Exception {
    	if (this.getAcCurrCode().equals(ACCURRCDSETCODE.toString()))
        {
            for (RimCoreActCdSets actCdSets : this.getActCdSetsList())
            {
                if (this.getAcCurrCode().equals(actCdSets.getAttributeTypeCode()))
                {
                    return DataTypeUtil.getCE(actCdSets);
                }
            }            
        }
        else
            return DataTypeUtil.getCE(this.getAcCurrCode()); 
        return null;
    }
/*
    public void setInterestRateQuantity(RTO_MO_PQ interestRateQuantity) {
        this.interestRateQuantity = interestRateQuantity;
    }

    public RTO_MO_PQ getInterestRateQuantity() {
        return interestRateQuantity;
    }
*/
    public void setName(ST name) {
        this.setAcAccountName(name.toString());
    }

    public ST getName() throws Hl7Exception {
        return DataTypeUtil.getST(this.getAcAccountName());  
    }
    
    //Account
        @Column(name = "AC_ACCOUNT_NAME")    protected String acAccountName;
        @Column(name = "AC_ALLOWED_BAL_END_CURR_CODE")    protected String acAllowedBalEndCurrCode;
        @Column(name = "AC_ALLOWED_BAL_END_INCL_FLAG")    protected String acAllowedBalEndInclFlag;
        @Column(name = "AC_ALLOWED_BAL_IVL_CURR_CODE")    protected String acAllowedBalIvlCurrCode;
        @Column(name = "AC_ALLOWED_BAL_QTY_END_AMT")    protected Double acAllowedBalQtyEndAmt;
        @Column(name = "AC_ALLOWED_BAL_QTY_END_TXT")    protected String acAllowedBalQtyEndTxt;
        @Column(name = "AC_ALLOWED_BAL_QTY_IVL_TXT")    protected String acAllowedBalQtyIvlTxt;
        @Column(name = "AC_ALLOWED_BAL_QTY_START_AMT")    protected Double acAllowedBalQtyStartAmt;
        @Column(name = "AC_ALLOWED_BAL_QTY_START_TXT")    protected String acAllowedBalQtyStartTxt;
        @Column(name = "AC_ALLOWED_BAL_START_CURR_CODE")    protected String acAllowedBalStartCurrCode;
        @Column(name = "AC_ALLOWED_BAL_START_INCL_FLAG")    protected String acAllowedBalStartInclFlag;
        @Column(name = "AC_BALANCE_AMT")    protected Double acBalanceAmt;
        @Column(name = "AC_BALANCE_AMT_TXT")    protected String acBalanceAmtTxt;
        @Column(name = "AC_BAL_AMT_CURR_CODE")    protected String acBalAmtCurrCode;
        @Column(name = "AC_CURR_CODE")    
        protected String acCurrCode = ACCURRCDSETCODE.toString();
        @Column(name = "AC_DEN_INTT_RATE_QTY_TXT")    protected String acDenInttRateQtyTxt;
        @Column(name = "AC_DEN_INTT_RATE_QTY_UOM_CODE")    protected String acDenInttRateQtyUomCode;
        @Column(name = "AC_NUMER_INTT_RATE_CURR_CODE")    protected String acNumerInttRateCurrCode;
        @Column(name = "AC_NUMER_INTT_RATE_QTY_AMT")    protected Double acNumerInttRateQtyAmt;
        @Column(name = "AC_NUMER_INTT_RATE_QTY_TXT")    protected String acNumerInttRateQtyTxt;
        

        protected String getAcAccountName() {
            return acAccountName;
        }
        
        protected void setAcAccountName(String acAccountName) {
            this.acAccountName = acAccountName;
        }

        protected String getAcAllowedBalEndCurrCode() {
            return acAllowedBalEndCurrCode;
        }
        
        protected void setAcAllowedBalEndCurrCode(String acAllowedBalEndCurrCode) {
            this.acAllowedBalEndCurrCode = acAllowedBalEndCurrCode;
        }

        protected String getAcAllowedBalEndInclFlag() {
            return acAllowedBalEndInclFlag;
        }

        protected void setAcAllowedBalEndInclFlag(String acAllowedBalEndInclFlag) {
            this.acAllowedBalEndInclFlag = acAllowedBalEndInclFlag;
        }

        protected String getAcAllowedBalIvlCurrCode() {
            return acAllowedBalIvlCurrCode;
        }

        protected void setAcAllowedBalIvlCurrCode(String acAllowedBalIvlCurrCode) {
            this.acAllowedBalIvlCurrCode = acAllowedBalIvlCurrCode;
        }

        protected Double getAcAllowedBalQtyEndAmt() {
            return acAllowedBalQtyEndAmt;
        }

        protected void setAcAllowedBalQtyEndAmt(Double acAllowedBalQtyEndAmt) {
            this.acAllowedBalQtyEndAmt = acAllowedBalQtyEndAmt;
        }

        protected String getAcAllowedBalQtyEndTxt() {
            return acAllowedBalQtyEndTxt;
        }

        protected void setAcAllowedBalQtyEndTxt(String acAllowedBalQtyEndTxt) {
            this.acAllowedBalQtyEndTxt = acAllowedBalQtyEndTxt;
        }

        protected String getAcAllowedBalQtyIvlTxt() {
            return acAllowedBalQtyIvlTxt;
        }

        protected void setAcAllowedBalQtyIvlTxt(String acAllowedBalQtyIvlTxt) {
            this.acAllowedBalQtyIvlTxt = acAllowedBalQtyIvlTxt;
        }

        protected Double getAcAllowedBalQtyStartAmt() {
            return acAllowedBalQtyStartAmt;
        }

        protected void setAcAllowedBalQtyStartAmt(Double acAllowedBalQtyStartAmt) {
            this.acAllowedBalQtyStartAmt = acAllowedBalQtyStartAmt;
        }

        protected String getAcAllowedBalQtyStartTxt() {
            return acAllowedBalQtyStartTxt;
        }

        protected void setAcAllowedBalQtyStartTxt(String acAllowedBalQtyStartTxt) {
            this.acAllowedBalQtyStartTxt = acAllowedBalQtyStartTxt;
        }

        protected String getAcAllowedBalStartCurrCode() {
            return acAllowedBalStartCurrCode;
        }

        protected void setAcAllowedBalStartCurrCode(String acAllowedBalStartCurrCode) {
            this.acAllowedBalStartCurrCode = acAllowedBalStartCurrCode;
        }

        protected String getAcAllowedBalStartInclFlag() {
            return acAllowedBalStartInclFlag;
        }

        protected void setAcAllowedBalStartInclFlag(String acAllowedBalStartInclFlag) {
            this.acAllowedBalStartInclFlag = acAllowedBalStartInclFlag;
        }

        protected Double getAcBalanceAmt() {
            return acBalanceAmt;
        }

        protected void setAcBalanceAmt(Double acBalanceAmt) {
            this.acBalanceAmt = acBalanceAmt;
        }

        protected String getAcBalanceAmtTxt() {
            return acBalanceAmtTxt;
        }

        protected void setAcBalanceAmtTxt(String acBalanceAmtTxt) {
            this.acBalanceAmtTxt = acBalanceAmtTxt;
        }

        protected String getAcBalAmtCurrCode() {
            return acBalAmtCurrCode;
        }

        protected void setAcBalAmtCurrCode(String acBalAmtCurrCode) {
            this.acBalAmtCurrCode = acBalAmtCurrCode;
        }

        protected String getAcCurrCode() {
            return acCurrCode;
        }

        protected void setAcCurrCode(String acCurrCode) {
            this.acCurrCode = acCurrCode;
        }

        protected String getAcDenInttRateQtyTxt() {
            return acDenInttRateQtyTxt;
        }

        protected void setAcDenInttRateQtyTxt(String acDenInttRateQtyTxt) {
            this.acDenInttRateQtyTxt = acDenInttRateQtyTxt;
        }

        protected String getAcDenInttRateQtyUomCode() {
            return acDenInttRateQtyUomCode;
        }

        protected void setAcDenInttRateQtyUomCode(String acDenInttRateQtyUomCode) {
            this.acDenInttRateQtyUomCode = acDenInttRateQtyUomCode;
        }

        protected String getAcNumerInttRateCurrCode() {
            return acNumerInttRateCurrCode;
        }

        protected void setAcNumerInttRateCurrCode(String acNumerInttRateCurrCode) {
            this.acNumerInttRateCurrCode = acNumerInttRateCurrCode;
        }

        protected Double getAcNumerInttRateQtyAmt() {
            return acNumerInttRateQtyAmt;
        }

        protected void setAcNumerInttRateQtyAmt(Double acNumerInttRateQtyAmt) {
            this.acNumerInttRateQtyAmt = acNumerInttRateQtyAmt;
        }

        protected String getAcNumerInttRateQtyTxt() {
            return acNumerInttRateQtyTxt;
        }

        protected void setAcNumerInttRateQtyTxt(String acNumerInttRateQtyTxt) {
            this.acNumerInttRateQtyTxt = acNumerInttRateQtyTxt;
        }


}
